<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加项目</title>
    <!-- 引入Bootstrap CSS -->
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
    <!-- 引入Bootstrap Datepicker CSS -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" rel="stylesheet">
    <!-- 引入Rich Text Editor CSS -->
    <link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-bs4.min.css" rel="stylesheet">

    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-bs4.min.js"></script>
    <script type="text/javascript">
        function validateForm() {
            var protectId = document.getElementById("protectId").value;
            var postId = document.getElementById("postId").value;

            if (isNaN(protectId) || isNaN(postId)) {
                alert("项目ID和岗位ID必须是整型数据");
                return false;
            }
            return true;
        }

        $(document).ready(function() {
            $('#startTime').datepicker({
                format: 'yyyy-mm-dd',
                autoclose: true,
                todayHighlight: true
            });
            $('#endTime').datepicker({
                format: 'yyyy-mm-dd',
                autoclose: true,
                todayHighlight: true
            });

            $('#description').summernote({
                height: 200,
                toolbar: [
                    ['style', ['style']],
                    ['font', ['bold', 'italic', 'underline', 'clear']],
                    ['fontname', ['fontname']],
                    ['color', ['color']],
                    ['para', ['ul', 'ol', 'paragraph']],
                    ['table', ['table']],
                    ['insert', ['link', 'picture', 'video']],
                    ['view', ['fullscreen', 'codeview', 'help']]
                ]
            });

            // 显示提示框
            <%
                String message = (String) request.getAttribute("message");
                if (message != null) {
            %>
            alert("<%= message %>");
            <%
                }
            %>
        });
    </script>
</head>
<body>
<div class="container">
    <h2 class="mt-5 text-center">添加项目</h2>
    <form action="addprojectservlet" method="post" onsubmit="return validateForm()">
        <div class="form-row">
            <div class="form-group col-md-6">
                <label for="protectId">项目ID:</label>
                <input type="text" class="form-control" id="protectId" name="protectId" required>
            </div>
            <div class="form-group col-md-6">
                <label for="projectName">项目名称:</label>
                <input type="text" class="form-control" id="projectName" name="projectName" required>
            </div>
        </div>
        <div class="form-row">
            <div class="form-group col-md-6">
                <label for="postId">导师ID:</label>
                <input type="text" class="form-control" id="postId" name="postId" required>
            </div>
            <div class="form-group col-md-6">
                <label for="postName">导师名称:</label>
                <input type="text" class="form-control" id="postName" name="postName" required>
            </div>
        </div>
        <div class="form-row">
            <div class="form-group col-md-6">
                <label for="type">类型:</label>
                <input type="text" class="form-control" id="type" name="type" required>
            </div>
            <div class="form-group col-md-6">
                <label for="startTime">开始时间:</label>
                <input type="text" class="form-control" id="startTime" name="startTime" required>
            </div>
        </div>
        <div class="form-row">
            <div class="form-group col-md-6">
                <label for="endTime">结束时间:</label>
                <input type="text" class="form-control" id="endTime" name="endTime" required>
            </div>
            <div class="form-group col-md-6">
                <label for="members">成员:</label>
                <input type="text" class="form-control" id="members" name="members" required>
            </div>
        </div>
        <div class="form-group">
            <label for="description">项目描述:</label>
            <textarea class="form-control" id="description" name="description"></textarea>
        </div>
        <button type="submit" class="btn btn-primary d-block mx-auto" style="width: 20%;">提交</button>
    </form>
</div>
</body>
</html>
